﻿
namespace PersonLookup.ViewModel
{
    public partial class Person
    {
        partial void AfterEndEdit()
        {
            if (this.EntityStatus == MVVM.EntityStatus.Original)
            {
                this.EntityStatus = MVVM.EntityStatus.Modified;
            }
        }

        partial void SaveCompleted(Person person, System.Exception error, object userState)
        {
            if (error == null)
            {
                this.ID = person.ID;
                this.EntityStatus = MVVM.EntityStatus.Original;
            }
        }

        partial void UpdateCompleted(int rowsAffected, System.Exception error, object userState)
        {
            if (error == null && rowsAffected == 1)
            {
                this.EntityStatus = MVVM.EntityStatus.Original;
            }
        }

        partial void DeleteCompleted(int rowsAffected, System.Exception error, object userState)
        {
            if (error != null)
            {
                // some way of error messaging
            }
        }
    }
}
